
public class Test {
    public static void main(String[] args) throws Exception {
        // 手动实现Thread构造函数的Runnable接口
        // java.lang.Thread.Thread(Runnable task)
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("t1 is runing");
            }
        });
        t1.start();
        t1.join();
        // 通过Lambda函数实现： 编译器自动推断lamdba函数类型Runnable
        Thread t2 = new Thread(() -> System.out.println("t2 is runing"));
        t2.start();
        t2.join();

        // 手动指定lambda函数类型后调用
        Runnable r2 = () -> System.out.println("r3 is runing");
        Thread t3 = new Thread(r2);
        t3.start();
        t3.join();
    }
}